<?php
	session_start();
	session_register("cart");
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
	<head>
	 <title>Demo Shopping Cart - Created By My Kenny</title>
	 <link rel="stylesheet" href="style.css" />
	 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	</head>
	<body>
	<style>
	body{
	font:12px verdana;
	}
	.pro{
	border:1px solid #999999;
	margin:5px;
	padding:5px;
	width:400px;
	}
	a{
	color:#666666;
	text-decoration:none;
font-weight:900;
	}
	#cart{
	border:1px solid #999999;
	margin:5px;
padding:5px;
	width:400px;
	text-align:center;
	}
	</style>
	<h1>GIỚI THIỆU CÁC SẢN PHẨM</h1>
	<div masp=cart>
	<?php
	//if(isset($_POST['submit']))
	//{
	 //foreach($_POST['qty'] as $key=>$value)
	// {
	 // if( ($value == 0) and (is_numeric($value)))
	 // {
	//   unset ($_SESSION['cart'][$key]);
	//  }
	 // elseif(($value > 0) and (is_numeric($value)))
	//  {
	//   $_SESSION['cart'][$key]=$value;
	//  }
	// }
//	 header("location:giohang.php");
//	}
?>
	
	<?php
 if(isset($_SESSION['cart']))
	 {
	  foreach($_SESSION['cart'] as $k=>$v)
	  {
	   if(isset($v))
	   {
	   $ok=2;
	   }
	  }
	 }
 if ($ok != 2)
	  {
	  echo '<p>Ban khong co mon hang nao trong gio hang</p>';
	 } else {
	  $items = $_SESSION['cart'];
	  echo '<p>Ban dang co <a href="giohang.php">'.count($items).' mon hang trong gio hang</a></p>';
 }
	?>
	</div>
	<?php
	$connect=mysql_connect("localhost","root","")
	or die("Can not connect database");
	mysql_select_db("linhkienmt",$connect);
	$sql="select * from sp order by masp desc";
	$query=mysql_query($sql);
if(mysql_num_rows($query) > 0)
	{
 while($row=mysql_fetch_array($query))
	 {
	  echo "<div class=pro>";
	  echo "<h3>$row[title]</h3>";
	  echo "Tên sản phẩm: $row[tensp] - dongia: ".number_format($row[dongia],3)." VND<br />";
	  echo "<p align=right><a href=addcart.php?item=$row[masp]>Mua sản phẩm này</a></p>";
	  echo "</div>";
	 }
	}
	   
	?>

</body>
</html>
